<template>

	<div>
		
		<div v-if="newList.length != 0" >
			<scroller lock-x @on-scroll-bottom="onScrollBottom" ref="scrollerBottom" :scroll-bottom-offst="0">

				<div>
	
					<div v-for="(item,index) in newList">
						<div class='list_forward'>
							<div class='flex-row' style="color:#9D9E9E">
								<div class='flex-grow-1'>申请时间：{{item.addtime}}</div>
								<div class='flex-grow-0' style="color:#ffb553">{{item.price}}元</div>
							</div>
							<div class='flex-row'>
								<div class='flex-grow-1' style="color:#9D9E9E">提现方式：微信钱包</div>
								<div class='flex-grow-0'>
									<div class='flex-row'>
										<div class='flex-grow-0'>状态：</div>
										<div class='flex-grow-0' style="color:#45B033">{{item.status}}</div>
									</div>
								</div>
							</div>
							<div class='flex-row'>
								<div class='flex-grow-1' style="color:#9D9E9E">备注：</div>
								<div class='flex-grow-0'>提现编号：35421</div>
							</div>
						</div>
						<div style="width: 100%; height: 0.6rem; background-color: #e4e4e5; border-top:1px #cfcfcf solid;"></div>
					</div>
	
					<load-more tip="loading" v-if="loading"></load-more>
	
				</div>
	
			</scroller>
		</div>
		

		<div v-if="newList.length == 0" style="margin: 1rem auto; width: 50%; text-align: center; color:#7b7a7a ">暂无更多内容！</div>
	</div>

</template>

<script>
	import {base64, DatetimeView, PopupPicker, XButton, Scroller, LoadMore } from 'vux'

	export default {

		components: {

			PopupPicker,
			XButton,
			DatetimeView,
			Scroller,
			LoadMore,
			base64

		},
		data() {
			return {

				access_token: '',
				list: '',
				none: true,
				
				onFetching: false,
		        loading:false,
		        newList:[],
		        page:1

			}
		},
		methods: {

			//获取详情
			getDetail() {

				this.$store.commit('updateLoadingStatus', true);

				this.$http.get(this.$store.state.api + 'userdd/cash-detail&access_token=' + this.access_token + '&page=' + this.page)
				.then((response) => {

					console.log(response)

					if(response.body.code == 0) {

						this.list = response.body.data.list
						
						for(var i = 0 ; i < response.body.data.list.length ; i ++){
					
							this.newList.push(this.list[i])
						
						}
						
						console.log(this.newList)

					} else {

					}

					this.$store.commit('updateLoadingStatus', false);

				}, (response) => {

				});

			},
			
			//触底加载
		    onScrollBottom:function(){
		      
		      if (this.onFetching) {
		        // do nothing
		      } else {
		        
		        
		        
		        console.log('开始')
		        
		        this.page = this.page + 1;
		        
		        console.log(this.page)
		        
		        this.getDetail();
		        
		        this.loading = true;
		        
		        
		        
		      this.onFetching = false
		        setTimeout(() => {
		
		
//		        this.info = this.info.concat(this.info);
		        this.onFetching = false
		          console.log('结束')
		          this.loading = false;
		        }, 500)
		        
		      }
		    },
		    
		    //获取地址栏信息
			getUrlStr(name){
		      let reg = new RegExp("(^|\\?|&)" + name + "=([^&]*)(\\s|&|$)","i");
		      if(reg.test(window.location.href)){
		        return unescape(RegExp.$2.replace(/\+/g," "))
		      }
		      return undefined
		    },	

		},

		mounted() {

			var access_token = this.getUrlStr('access_token');
           var parentId = this.getUrlStr('parent_id');
           
            if(parentId == undefined){
              parentId = 0;
           }
           
           var uid = this.getUrlStr('uid');
           
           if(parentId.toString().indexOf('?') > 0){
           	 parentId = parentId.split('?')[0];
           }
           
           var locurl = location.href;
           locurl = base64.encode(locurl.split('?')[0]);
           
       
           if(access_token != undefined){
         
              localStorage.setItem("access_token",access_token); 
              localStorage.setItem("parent_id",this.getUrlStr('uid'));


           }
           
            if(localStorage.getItem('access_token') != null){
         
              this.$root.registerjudge();
              this.$root.getShare();
              
            }else{
            	
        	  this.$root.gotoWechat(locurl,parentId);
            }
           
    	   this.access_token = localStorage.getItem('access_token');

			this.getDetail();

		},

	}
</script>

<style>
	.list {
		background: #fff;
		margin-bottom: 10px
	}
	
	.list_forward {
		padding: 0.8rem;
	}
</style>